package com.myproject.jvm;

public class Test {

    public static void main(String[] args) {
        Runtime runtime = Runtime.getRuntime();
        System.out.println("可用最大内存：" + runtime.maxMemory());
        System.out.println("空闲内存：" + runtime.freeMemory());
        System.out.println("当前可用内存：" + runtime.totalMemory());
        System.out.println("-------------------------------------------");
        byte[] bytes = new byte[1024*1024*4];
        System.out.println("可用最大内存：" + runtime.maxMemory());
        System.out.println("空闲内存：" + runtime.freeMemory());
        System.out.println("当前可用内存：" + runtime.totalMemory());
        System.out.println("-------------------------------------------");
        bytes = new byte[1024*1024*4];
        System.out.println("可用最大内存：" + runtime.maxMemory());
        System.out.println("空闲内存：" + runtime.freeMemory());
        System.out.println("当前可用内存：" + runtime.totalMemory());
    }
}
